
#ifndef __EVENT_BASE_H__
#define __EVENT_BASE_H__

#include "core/Obj.h"
#include <string>

/*
    事件基础类

*/

class EventBase : public Obj
{
private:
    friend class EventDispatch;

    Obj* dispatcher_;
    Obj* info_;
    std::string name_;
   
public:
    EventBase();
    EventBase(Obj* info);
    EventBase(Obj* info, Obj* dispatcher);
    virtual ~EventBase() = default;

    // 获取事件派发者
    template<typename Type>
    Type* GetDispatcher(){
        if(this->_dispatcher == nullptr)
            return nullptr;
        return dynamic_cast<Type*>(this->_dispatcher);
    }

    // 获取事件信息
    template<typename Type>
    Type* GetInfo(){
        if(this->_info == nullptr)
            return nullptr;
        return dynamic_cast<Type*>(this->_info);
    }

    // 获取事件名
    const std::string& GetName();
};

#endif
